<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>四级项目1.2</title>
</head>
<body>
<script>

  var arr = [7, 9, 6, 2, 5, 1, 0, 3, 8, 4];

  var min = Infinity;
  var max = -Infinity;
  var minIndex = -1;
  var maxIndex = -1;


  for (var i = 0; i < arr.length; i++) {
    if (arr[i] < min) {
      min = arr[i];
      minIndex = i;
    }
    if (arr[i] > max) {
      max = arr[i];
      maxIndex = i;
    }
  }

  console.log("最小值:", min, " index:", minIndex);
  console.log("最大值:", max, " index:", maxIndex);
</script>
</body>
</html>
